<template>
    <div>
        <Col span="12">
            <Card>
                <p slot="title" style="height:25px;">
                    <Icon type="plus-round"></Icon> 提货详情
                </p>
                <Form :label-width="80">
                    <Form-item label="订单ID">{{formValidate.order_id}}</Form-item>
                    <Form-item label="提货卡ID">{{formValidate.card_id}}</Form-item>
                    <Form-item label="配送地址">{{formValidate.card_address.province+formValidate.card_address.city+formValidate.card_address.district+formValidate.card_address.full_address}}</Form-item>
                    <Form-item label="用户留言">{{formValidate.leave_words}}</Form-item>
                    <Form-item label="配送状态">{{formValidate.status==1?'已配送':'未配送'}}</Form-item>
                    <Form-item v-if="formValidate.status==0">
                        <Button type="primary" @click="handleExpress()">确认已配送</Button>
                    </Form-item>
                </Form>
            </Card>
        </Col>

    </div>
</template>

<script>
    export default {
        components:{

        },
        data () {
            return {
                card_id: 0,
                currentStatus: 0,
                formValidate: {},
            }
        },
        methods: {
            handleExpress () {
                this.$http.post('admin/order/handleExpress', {card_id: this.card_id}).then((res) => {
                    var d = res.data;
                    if (d.code == 0) {
                        this.$Notice.success({
                            title: 'Success',
                            desc: '操作成功'
                        });
                        this.$router.push({
                            name: 'cardList'
                        });
                    } else {
                        this.$Notice.error({
                            title: 'Error Warning',
                            desc: `Error：${d.msg}<br>`
                        });
                    }
                });
            },
            getOne () {
                this.$http.post('admin/order/getOneCard', this.$qs.stringify({card_id: this.card_id})).then((res) => {
                    var d = res.data;
                    if (d.code == 0) {
                        this.formValidate = d.data;
                    } else {
                        this.$Notice.error({
                            title: 'Error Warning',
                            desc: `Error：${d.msg}<br>`
                        });
                    }
                });
            },
        },
        mounted() {
            this.$nextTick(() => {
                this.card_id = this.$route.query.card_id;
                if (this.card_id) {
                    this.getOne();
                }
            });
        },
    };
</script>
